﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartSpace.Attendance
{
    public partial class AttendanceService : IAttendanceService
    {
        public ServiceResult SaveRecord(Record record)
        {
            using (AttendanceDbContext context = new AttendanceDbContext())
            {
                SmartSpace.Core.EntityRepository.Save<Record>(record, context);
                return new ServiceResult(true);
            }
        }

        public Record GetRecord(string account, DateTime date)
        {
            using (AttendanceDbContext context = new AttendanceDbContext())
            {
                return context.Set<Record>().Where(p => p.Account == account && p.Date == date)
                    .SingleOrDefault();
            }
        }
    }
}
